home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Hash_InitTable C Library Procedures Hash_InitTable
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Hash_InitTable - set up new hash table
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<hhaasshh..hh>>
-
- Hash_InitTable(_t_a_b_l_e_P_t_r, _n_u_m_B_u_c_k_e_t_s, _k_e_y_T_y_p_e)
-
- AARRGGUUMMEENNTTSS
- Hash_Table *_t_a_b_l_e_P_t_r (in) Structure to use to hold
- information about hash
- table. Caller must have
- allocated space at
- *tablePtr, but need not
- have initialized con-
- tents.
-
- int _n_u_m_B_u_c_k_e_t_s (in) How many buckets should
- be in table initially.
- If <= 0, a reasonable
- default will be chosen.
- In any case, the number
- of buckets will change
- dynamically as the
- number of entries in the
- table grows.
-
- int _k_e_y_T_y_p_e (in) What type of keys will
- be used for table:
- HHAASSHH__SSTTRRIINNGG__KKEEYYSS,
- HHAASSHH__OONNEE__WWOORRDD__KKEEYYSS, or
- integer >= 2.
-
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- HHaasshh__IInniittTTaabbllee initializes a Hash_Table structure and sets
- up bucket storage for the table, with no entries in the
- table initially. It must be called before any other opera-
- tions are performed on the hash table.
-
- The _k_e_y_T_y_p_e argument indicates what type of keys will be
- used in the table. HASH_STRING_KEYS means that all keys
- will be strings, and that the _k_e_y argument to procedures
- like Hash_FindEntry will be passed in as a string:
-
-
- Hash_Table table;
- Hash_Entry *entryPtr;
- char *key = "foobar";
-
-
-
-
- Sprite v.1.0 Printed: February 13, 1989 1
-
-
-
-
-
-
- Hash_InitTable C Library Procedures Hash_InitTable
-
-
-
- Hash_InitTable(&table, 0, HASH_STRING_KEYS);
- entryPtr = Hash_FindEntry(&table, key);
-
- If _k_e_y_T_y_p_e is HASH_ONE_WORD_KEYS, then keys will be one-word
- (Address) values; _k_e_y arguments passed to procedures like
- HHaasshh__FFiinnddEEnnttrryy may be integers or any other values of the
- same size as addresses, passed by casting the value to an
- Address:
-
-
- Hash_Table table;
- Hash_Entry *entryPtr;
- int key = 24;
-
- Hash_InitTable(&table, 0, HASH_ONE_WORD_KEYS);
- entryPtr = Hash_FindEntry(&table, (Address) key);
-
- Finally, if _k_e_y_T_y_p_e is an integer greater than 1, then keys
- are multi-word values containing _k_e_y_T_y_p_e words (not bytes!),
- passed into procedures like HHaasshh__FFiinnddEEnnttrryy by address:
-
-
- Hash_Table table;
- Hash_Entry *entryPtr;
- int key[6] = {1,2,3,4,5,6};
-
- Hash_InitTable(&table, 0, 6);
- entryPtr = Hash_CreateEntry(tablePtr, (Address) key);
-
-
- KKEEYYWWOORRDDSS
- hash table, initialization, key
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v.1.0 Printed: February 13, 1989 2
-
-
-
-